package com.zjj.springstu.springHandwriting.app.service.beanPostProcessor;

import com.zjj.springstu.springHandwriting.app.service.UserService;
import com.zjj.springstu.springHandwriting.framework.annotation.Component;
import com.zjj.springstu.springHandwriting.framework.intf.BeanPostProcessor;

/**
 * @author zhanglei.zjj
 * @description 定制BeanPostProcessor
 * @date 2023/4/11 20:39
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) {
        if (beanName.equals("userService1")) {
            UserService userService = (UserService) bean;
            userService.setAge(26);
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) {
        return bean;
    }
}
